import request from '@/utils/request';

/**
 * 通知公告列表
 * @returns
 */
export const fetchNotices = (params: any) => {
  return request({
    url: 'notice/list',
    params,
  });
};

/**
 * 新增公告
 * @returns
 */
export const createNotice = (data: any) => {
  return request({
    url: 'notice/add',
    method: 'POST',
    data,
  });
};

/**
 * 删除通知公告
 * @returns
 */
export const deleteNotice = (id: number) => {
  return request({
    url: `notice/delete/${id}`,
    method: 'DELETE',
  });
};

/***********************************登录日志***********************************/
/**
 * 登录日志
 * @returns
 */
export const fetchLoginLogs = (params: any) => {
  return request({
    url: `monitor/logininfor/list`,
    params,
  });
};

/**
 * 解锁用户登录状态
 */
export function unlockLogininfor(userName: any) {
  return request({
    url: `/monitor/logininfor/unlock/${userName}`,
    method: 'get',
  });
}

/**
 * 登录日志导出
 */
export const exportLoginLogs = () => {
  return request({
    url: 'monitor/logininfor/export',
    method: 'POST',
    responseType: 'blob',
  });
};

/***********************************操作日志***********************************/
/**
 * 操作日志
 */
export const fetchOperationLogs = (params: any) => {
  return request({
    url: 'monitor/operlog/list',
    params,
  });
};

/**
 * 操作日志导出
 */
export const exportOperationLogs = () => {
  return request({
    url: '/monitor/operlog/export',
    method: 'POST',
    responseType: 'blob',
  });
};

/***********************************告警日志***********************************/
/**
 * 查询告警记录列表
 */
export function listLog(query: any) {
  return request({
    url: '/alarmLog/list',
    method: 'get',
    params: query,
  });
}

/**
 * 查询告警记录详细
 */
export function getLog(alarmId: any) {
  return request({
    url: `/alarmLog/${alarmId}`,
    method: 'get',
  });
}

/**
 * 新增告警记录
 */
export function addLog(data: any) {
  return request({
    url: '/alarmLog',
    method: 'post',
    data: data,
  });
}

/**
 * 修改告警记录
 */
export function updateLog(data: any) {
  return request({
    url: '/alarmLog',
    method: 'put',
    data: data,
  });
}

/**
 * 删除告警记录
 */
export function delLog(alarmId: any) {
  return request({
    url: `/alarmLog${alarmId}`,
    method: 'delete',
  });
}

/**
 * 告警配置查询
 */
export function getAlarmConfig() {
  return request({
    url: '/alarmConfig/list',
    method: 'get',
  });
}

/**
 * 告警配置新增
 */
export function addAlarmConfig(data: any) {
  return request({
    url: '/alarmConfig',
    method: 'POST',
    data,
  });
}

/**
 * 告警配置更新
 */
export function upAlarmConfig(data: any) {
  return request({
    url: '/alarmConfig',
    method: 'PUT',
    data,
  });
}

//设备操作记录列表
export function deviceOperateList(params: any) {
  return request({
    url: '/deviceOperate/list',
    method: 'get',
    params,
  });
}

export const exportDeviceOperate = (data: any) => {
  return request({
    url: `/deviceOperate/export`,
    method: 'POST',
    responseType: 'blob',
    data,
  });
};

export function saveRecord(data: any) {
  return request({
    url: '/deviceOperate/saveRecord',
    method: 'POST',
    data,
  });
}
